package org.helsoft.mojo.api;

import java.io.File;
import java.io.FileFilter;

public class ExtensionFilter implements FileFilter {
	private String ext;
	
	public ExtensionFilter(String extension) {
		ext = extension == null ? "" : extension.toLowerCase();
		if (!ext.startsWith(".")) {
			ext = "." + ext;
		}
	}
	
	@Override
	public boolean accept(File pathname) {
		return pathname.isFile() && pathname.getName().toLowerCase().endsWith(ext);
	}

}
